//将评论集合构造函数导入
const {
    Comment
} = require('../../model/comment');

module.exports = async (req, res) => {
    const {
        content,
        uid,
        aid
    } = req.body;

    // return res.send("评论成功")


    //将评论信息存储到评论集合中
    await Comment.create({
        content: content,
        uid: uid,
        aid: aid,
        time: new Date()
    })


    let comment = await Comment.find({
        aid: aid
    })
    // return res.send(comment)

    // res.send(comment)
    // res.render('home/article',{
    //     comment:comment
    // })

    //将页面重定向到文章详情也没眼
    res.redirect('/home/article?id=' + aid);



}